function create_deformed_img_slices_toolbox(patient)
    
    
    
    %
    %   [ dvf,static, static_mask, folder, folder_static]=read_dvf_elastix_cut2(scans,ref,folder_static,model_folder);
    
    img_tmp = patient.static;
    fileinfo = whos('img_tmp')
    fileSize = fileinfo.bytes/1E6
    % [ img]=read_deformed_img_slice_toolbox(patient);
    
    if fileSize < 400;
        
        for i=patient.ref:patient.scans;
            
            display(sprintf('Reading Deformed IMG; scan = %d of %d',i, patient.scans))
            folder_dvf=[patient.folder_elastix sprintf('/out_phase%d_phase%d',patient.ref,i)];
            
            
            img(i,:,:,:)=single(metaImageRead([folder_dvf '/result.0']));
            
        end
        
        img_tmp=zeros(patient.scans,patient.dim(2),patient.dim(3));
        
        for slice=1:patient.dim(1);
            
            img_tmp=squeeze(img(:,slice,:,:));
            save([ patient.image_slice_folder sprintf('/deformed_images_slice_%d',slice)],'img_tmp')
            
        end
        
    else
        
          slices_1=1:round(patient.dim(1)/2);
        for i=patient.ref:patient.scans;
            
            display(sprintf('Reading Deformed IMG; scan = %d of %d',i, patient.scans))
            folder_dvf=[patient.folder_elastix sprintf('/out_phase%d_phase%d',patient.ref,i)];
            
            img_tmp = single(metaImageRead([folder_dvf '/result.0']));
            img(i,:,:,:)= single(img_tmp(slices_1,:,:));
            
        end
        
        img_tmp=zeros(patient.scans,patient.dim(2),patient.dim(3));
        
        for slice=slices_1;%1:patient.dim(1);
            
            img_tmp=squeeze(img(:,slice,:,:));
            save([ patient.image_slice_folder sprintf('/deformed_images_slice_%d',slice)],'img_tmp')
            
        end
         slices_2=round(patient.dim(1)/2)+1:patient.dim(1);
        for i=patient.ref:patient.scans;
            
            display(sprintf('Reading Deformed IMG; scan = %d of %d',i, patient.scans))
            folder_dvf=[patient.folder_elastix sprintf('/out_phase%d_phase%d',patient.ref,i)];
            
            img_tmp = single(metaImageRead([folder_dvf '/result.0']));
            img(i,:,:,:)= single(img_tmp(slices_2,:,:));
            
        end
        
        img_tmp=zeros(patient.scans,patient.dim(2),patient.dim(3));
        
        for slice=slices_2;%1:patient.dim(1);
            
            img_tmp=squeeze(img(:,slice-slices_2(1)+1,:,:));
            save([ patient.image_slice_folder sprintf('/deformed_images_slice_%d',slice)],'img_tmp')
            
        end
    end
    
